<%--
  Created by IntelliJ IDEA.
  User: hejiahao
  Date: 2021/12/17
  Time: 15:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import ="java.sql.*"%>
<%
    request.setCharacterEncoding("UTF-8");
    String goodscode = request.getParameter("goodscode");
    String goodsname = request.getParameter("goodsname");
    String specification = request.getParameter("specification");
    String prices = request.getParameter("prices");
    String describe = request.getParameter("describe");
//UserName = '"+ UserName +"',
    String Sql = "update goods set goodsname = '" + goodsname
            +"',specification = '" + specification
            +"',prices = '" + prices
            +"',`describe` = '" + describe
            +"' where goodscode = '"+goodscode+"';";
//注册加载一个Driver驱动
    try {
        Class.forName("com.mysql.cj.jdbc.Driver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
//获取数据库连接
    String jdbcURL = "jdbc:mysql://127.0.0.1:3306/goodslist?characterEncoding=UTF-8";
    Connection con = DriverManager.getConnection(jdbcURL,"root","123456");
//创建SQL命令对象
    Statement sm = con.createStatement();
//通过SQL命令对象执行SQL语句
    sm.execute(Sql); // insert \ update \ delete
//释放所有对象
    if (sm != null){
        sm.close();
    }
    if (con != null){
        con.close();
    }
    response.sendRedirect("list.jsp");
%>
<html>
<head>
    <title>Save</title>
</head>
<body>

</body>
</html>
